<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">-->
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <!-- Map loader -->
    <!-- <script src="http://maps.google.com/maps?file=api&amp;v=2" type="text/javascript"></script> -->
    <script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAATzYHx1-XL36zRB3eYwjxART2yXp_ZAY8_ufC3CFXhHIE1NvwkxS5rxqZkoEkahKFutilQayue0IKPQ"
      type="text/javascript"></script>
    <script type="text/javascript">
    //<![CDATA[
var map; //GMap
var dmap;
var geocoder; //GClientGeocoder
var VIEW_ROAD = 0x00000001;//road view
var VIEW_SATELLITE = 0x00000002;//road view
var VIEW_TRAFFIC = 0x00000004;//traffic view
var VIEW_3D  = 0x00010000; //road view 
var VIEW_25D = 0x00020000; //landscape view

/**
* Informs Java about available views
* @return the combination of VIEW_XXXX consts
*/
function _availuableViews(){
    return VIEW_ROAD | VIEW_SATELLITE | VIEW_TRAFFIC | VIEW_25D;
}

var PlaneDecoder = [
    G_NORMAL_MAP, //default
    G_NORMAL_MAP, //VIEW_ROAD
    G_SATELLITE_MAP, //VIEW_SATELLITE
    G_HYBRID_MAP //VIEW_SATELLITE | VIEW_ROAD
];

/**
* Set selected view style.
* @param address the string with an address
*/
function _findAddress(address) {
    geocoder.getLatLng(
        address,
        function(ll) {
            //alert("aa:" + ll);
            window.status =  "javaevent,foundAddress"
                +( ll?("," + ll.lat() + "," + ll.lng()):"");
        }
    );
}
/**
* Set selected view style.
* @param view the combination of VIEW_XXXX consts
*/
function _setView(view){
    map.setMapType(PlaneDecoder[view & 3]);        
}

/**
* Get current view style.
* @return the integer combination of VIEW_XXXX consts
*/
function _getView(){
    var map_view = 0;
    var ms = map.getCurrentMapType();
    if( G_NORMAL_MAP==ms )
        map_view |= VIEW_ROAD;
    else if( G_SATELLITE_MAP==ms )
        map_view |= VIEW_SATELLITE;
    else if( G_HYBRID_MAP==ms )
        map_view |= VIEW_SATELLITE | VIEW_ROAD;
    return map_view;
}

/**
* String property Center getter
* @return the string with center "Latitude, Longitude"
*/
function _getCenter(){
    var center = map.getCenter();    
    return  center.lat() + "," + center.lng();
}

/**
* String property Center getter
* @param centerLatitude center latitude
* @param centerLongitude center longitude
*/
function _setCenter(centerLatitude, centerLongitude){
    map.setCenter(new GLatLng(centerLatitude, centerLongitude));
}

/**
* Integer ZoomLevel property getter
* @return the integer zoom level
*/
function _getZoomLevel(){
    return map.getZoom();
}

/**
* Integer ZoomLevel property setter
* @param zoomLevel the integer zoom level
*/
function _setZoomLevel(zoomLevel){
    return map.setZoom(zoomLevel);
}

/**
* String property ViewDescriptor getter
* @return the string with center "Latitude, Longitude, ZoomLevel, ViewType"
*/
function _getViewDescriptor(){
     return _getCenter() + "," 
         + _getZoomLevel() + "," 
         + _getView();
}

/**
* String property ViewDescriptor setter 
* @param Latitude?  the double value of center Latitude
* @param Longitude? the double value of center Longitude
* @param ZoomLevel? the int value of zoom level 
* @param ViewType?  the combination of VIEW_XXXX consts 
*/
function _setViewDescriptor(){
    if( 3 <= arguments.length ) {
        map.setCenter(new GLatLng(arguments[0], arguments[1]), arguments[2]);        
    }
    if( 4 <= arguments.length ) {
        _setView(arguments[3]);
    }
}

function _onsize(){
    map.checkResize();
}

var event_returnValue = false;
var event_cancelBubble = false;
function map_onmousemove(){    
    event_returnValue = false;
    event_cancelBubbling = false;
    window.status =  "javaevent"
        + "," + event.type
        + "," + event.x 
        + "," + event.y
        + "," + event.button;
    event.cancelBubble = event_cancelBubble;
    return event_returnValue;
}

function map_zoomchanged(oldZoomLevel, newZoomLevel) {    
    window.status =  "javaevent,zoomchanged" 
        + "," + _getZoomLevel();
    map_centerchanged();
}        

function map_centerchanged() {    
    window.status =  "javaevent,centerchanged" 
        + "," + _getCenter();
}   

function _onload(){
    //if (GBrowserIsCompatible()) {
        dmap = document.getElementById("map");
        //dmap.onmousemove = map_onmousemove;
        //dmap.onmouseup = map_onmousemove;
        //dmap.onmousedown = map_onmousemove;
                
        map = new GMap2(dmap);
        geocoder = new GClientGeocoder();

        //map.addControl( new GLargeMapControl() );
        //map.addControl( new GMapTypeControl() );
        //map.addControl( new GTrafficOverlay() );
                
        GEvent.addDomListener(dmap, "mousemove", map_onmousemove);
        GEvent.addDomListener(dmap, "mouseup", map_onmousemove);
        GEvent.addDomListener(dmap, "mousedown", map_onmousemove);                
        GEvent.addListener(map, "zoomend", map_zoomchanged);
        GEvent.addListener(map, "moveend", map_centerchanged);

        //_onsize();
        /*                     
        if(null!=document.location.search){
            //eval( "_setViewDescriptor(" + document.location.search.substr(1) + ");" );
             var args = document.location.search.substr(1).split(",");                
            _setViewDescriptor(parseInt(args[0]), parseInt(args[1]), parseInt(args[2]), parseInt(args[3]));            
        } else {
            _setViewDescriptor(30.01, -122.4, 5, 2);
        }
        */
        window.status =  "javaevent,viewrequest";        
        window.status =  "javaevent,mapready";
    //}
}

function _fromLatLngToPoint(){
   var numargs = arguments.length;
   var ret = "";
   var shift = map.fromLatLngToDivPixel(
           map.fromContainerPixelToLatLng(new GPoint(0, 0))
   );
   for(var i=0 ; i < numargs; i+=2 ){
      var p = map.fromLatLngToDivPixel( new GLatLng(arguments[i], arguments[i+1]) );
      if(0!=ret.length){
          ret +=",";
      }
      ret += (p.x - shift.x)  + "," + (p.y - shift.y);
   }
   return ret;
}

function _fromPointToLatLng(){
   var numargs = arguments.length;
   var ret = "";
   for(var i=0 ; i < numargs; i+=2 ){
      var ll = map.fromContainerPixelToLatLng(new GPoint(arguments[i], arguments[i+1]) );
      if(0!=ret.length){
          ret +=",";
      }
      ret += ll.lat() + "," + ll.lng();
   }
   return ret;
}

//]]>
    </script>
</head>
<body style="border:none; margin: 0px 0px 0px 0px; " onunload="GUnload()" onload="_onload();" scroll="no" scrolling="no">
<div id="map" style="border:none; width:100%; height:100%; margin: 0px 0px 0px 0px;">
    <div style="padding: 1em; color: gray">Loading...</div>
</div>
</body>
</html>